package com.example.jk.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.jk.entity.JUser;
import com.example.jk.service.JUserService;
import com.example.jk.mapper.JUserMapper;
import com.example.jk.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
* @author 谭博宇
* @description 针对表【j_user】的数据库操作Service实现
* @createDate 2025-06-30 15:45:46
*/
@Service
public class JUserServiceImpl extends ServiceImpl<JUserMapper, JUser>
    implements JUserService{
    @Autowired
    private JUserMapper juserMapper;
    @Override
    public Result selectPage(JUser jUser) {
        Page<JUser> page = new Page<JUser>(jUser.getPage(),jUser.getSize());
        //2、查询条件
        QueryWrapper<JUser> queryWrapper = new QueryWrapper<JUser>();
        if(jUser.getUsername()!=null&&!"".equals(jUser.getUsername())){
            queryWrapper.like("user_name",jUser.getUsername());
        }
        if(jUser.getPassword()!=null&&!"".equals(jUser.getPassword())){
            queryWrapper.like("user_Password",jUser.getPassword());
        }

        //3、分页查询
        juserMapper.selectPage(page,queryWrapper);
        List<JUser> list = page.getRecords();//获取查询数据
        long total = page.getTotal();//总行数
        HashMap<String,Object> hashMap = new HashMap<String,Object>();
        hashMap.put("list",list);
        hashMap.put("total",total);
        return new Result(200,"查询成功",hashMap);
    }

    @Override
    public Result aiLogin(String s, String newName, String s1) {
        return null;
    }

    @Override
    public Integer getUserId(JUser user) {
        return null;
    }
}




